﻿Imports System.Xml

Namespace Stories
	Public Class Footnote
		Inherits Child

		Public Sub New()
			Children = New List(Of Child)
		End Sub

		Private Property Children As List(Of Child)

		Shared Function ReadXml(reader As XmlReader) As Footnote
			Dim fn As New Footnote

			While reader.Read()
				Select Case reader.Name
					Case "GaijiOwnedItemObject"
						fn.Children.Add(GaijiOwnedItemObject.ReadXml(reader))
					Case "TextVariableInstance"
						fn.Children.Add(TextVariableInstance.ReadXml(reader))
					Case "Table"
						fn.Children.Add(Table.ReadXml(reader))
					Case "ParagraphStyleRange"
						fn.Children.Add(ParagraphStyleRange.ReadXml(reader))
					Case "CharacterStyleRange"
						fn.Children.Add(CharacterStyleRange.ReadXml(reader))
					Case "HiddenText"
						fn.Children.Add(HiddenText.ReadXml(reader))
					Case "Note"
						If reader.NodeType = XmlNodeType.EndElement Then Exit While
					Case Else
						Debug.WriteLine("Unrecognized element: {0} in element: {1}", reader.Name, "Note")
				End Select
			End While

			Return fn
		End Function

	End Class
End Namespace